/**
 * @author 程文智
 */
package com.taxsystem.chengwenzhi.personal_notices;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.main.taxsystem.R;

public class PersonalNoticeAdapter extends CursorAdapter {
	private Context mContext = null;
	private LayoutInflater mInflater = null;
	private TextView titleView = null;
	private TextView createTimeView = null;
	private ImageView unreadFlagView = null;

	public PersonalNoticeAdapter(Context context, Cursor c, boolean autoRequery) {
		super(context, c, autoRequery);
		mContext = context;  
        mInflater = LayoutInflater.from(context);  
	}

	public PersonalNoticeAdapter(Context context, Cursor c, int flags) {
		super(context, c, flags);
		mContext = context;  
        mInflater = LayoutInflater.from(context);  
	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		return mInflater.inflate(R.layout.personal_notices_list_item,parent,false);
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		 titleView = (TextView) view.findViewById(R.id.notation_title);
		 createTimeView = (TextView) view.findViewById(R.id.notation_create_time);
		 unreadFlagView = (ImageView) view.findViewById(R.id.unread_flag);
		 String title  = cursor.getString(cursor.getColumnIndex("notationTitle"));
		 String createTime = cursor.getString(cursor.getColumnIndex("createTime"));
		 int unread = cursor.getInt(cursor.getColumnIndex("unread"));
		 titleView.setText(title);
		 createTimeView.setText(createTime);
		 if(0==unread)
		 unreadFlagView.setVisibility(View.INVISIBLE);
	}
}
